<template>
  <div class="res_content">
    <el-card class="res_card">
      <img :src="resRight" class="img_content" />
      <div class="res_msg">注册成功 {{ count }} 秒后自动跳转登录</div>
      <div>
        <el-button
          type="primary"
          style="margin-top: 10px"
          @click.once="toLogin"
        >
          立即登录
        </el-button>
      </div>
    </el-card>
  </div>
</template>
<script setup lang="ts">
import resRight from "@/assets/register/res_right.png";
import { useRouter } from "vue-router";
const router = useRouter();
let toTime: NodeJS.Timeout;
let tocount: NodeJS.Timeout;
const count = ref(3);
function toLogin() {
  router.push("/login");
}

function countDown() {
  tocount = setInterval(() => {
    if (count.value > 0) count.value--;
  }, 1000);
}

onMounted(() => {
  countDown();
  toTime = setTimeout(() => {
    router.push("login");
  }, 3000);
});

onUnmounted(() => {
  clearTimeout(toTime);
  clearInterval(tocount);
});
</script>
<style lang="scss" scoped>
.res_card {
  width: 90%;
  height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
:deep() .el-card__body {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.res_content {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  //height: 100vh;
}

.res_msg {
  font-size: 10px;
  margin-top: 30px;
}

.img_content {
  width: 150px;
  height: 100px;
}

.circle {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: auto;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  // border: 1px solid #ccc;
  background-color: #06eea8;
}

/* 在圆圈里面打一个勾 */
.circle:before {
  content: "\2713";
  font-family: "Times New Roman", Times, serif;
  display: block;
  font-size: 60px;
  color: #fff;
  text-align: center;
  line-height: 100px;
}
</style>
